<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Autocomplete extends MY_Controller {
	function index(){
		$this->layout->view('search/autocomplete');
	}
	
	function get_Names(){
		$data = array();
		
		$q = $this->input->get_post('q',true);
		$this->load->model('search_model');
		
		$items = $this->search_model->getAutoComplete($q);
		
		//echo "[";
        foreach ($items as $key=>$value) {
          //  if (strpos(strtolower($key), $q) !== false) {
            //    echo "{ name: '".$key."', to: '".$value."' }, ";
            //}
			echo "{$value['name']}\n";
        }
        //echo "]";
		
	}
}